package designpattern.strategy.practice;

/**
 * TODO:类描述
 *
 * @className: CompireContext
 * @packageName: designpattern.strategy.practice
 * @author: Zhuhj
 * @version: V1.0
 * @date: 2021/4/18 19:02
 */
public class CompireContext {
    public IPriceStrategy getiPriceStrategy() {
        return iPriceStrategy;
    }

    public void setiPriceStrategy(IPriceStrategy iPriceStrategy) {
        this.iPriceStrategy = iPriceStrategy;
    }

    private IPriceStrategy iPriceStrategy;
    public void compute(double a){
        double cc = iPriceStrategy.compute(a);
        System.out.println("价格:"+cc+"元");
    }

    public static void main(String[] args) {

        CompireContext cx = new CompireContext();
        cx.setiPriceStrategy(new FullReductionStrategy());
        cx.compute(400);
        cx.compute(90);

        cx.setiPriceStrategy(new DiscountStrategy());
        cx.compute(300);
        cx.compute(100);

    }
}
